<template>
    <div>
        <el-row :gutter="20" type="flex" class="operation">
            <el-col>
                <span>筛选器：</span>
                <el-select
                    v-model="fieldName"
                    placeholder="请选择字段名字"
                    class="search-select-parent"
                >
                    <el-option
                        v-for="item in fieldList"
                        :key="item.fieldName"
                        class="select-more-option"
                        :label="`${item.fieldName}(${item.fieldAlias})`"
                        :value="item.fieldName"
                        @click.native="handleSelectField(item)"
                    >
                        <!-- <el-tooltip  placement="top-start" effect="light">
							<p slot="content" class="margin-0">{{`${item.fieldName}(${item.fieldAlias})`}}</p>
							<p class="over-ellipsis-1 margin-0" style="width:200px;text-align:left;">{{`${item.fieldName}(${item.fieldAlias})`}}</p>
						</el-tooltip>			 -->
                        <p
                            class="over-ellipsis-1 margin-0"
                            style="width: 200px; text-align: left"
                        >
                            {{ `${item.fieldName}(${item.fieldAlias})` }}
                        </p>
                    </el-option>
                </el-select>
                <el-select
                    v-model="condition"
                    placeholder="请选择筛选条件"
                    class="search-select-child"
                >
                    <el-option
                        v-for="item in conditionList"
                        :key="item.val"
                        class="select-more-option"
                        :label="item.key"
                        :value="item.val"
                        @click.native="handleSelectCondition(item)"
                    />
                </el-select>
                <el-input
                    v-if="checkType != 'dateTime'"
                    v-model="leftVal"
                    class="search-select-child"
                    placeholder="请输入[a,b]中的a"
                    @input="watchContentHandle"
                />
                <el-input
                    v-if="isshowRight && checkType != 'dateTime'"
                    v-model="rightVal"
                    class="search-select-child"
                    oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
                    placeholder="请输入[a,b]中的b"
                    @input="watchContentHandle($event)"
                />
                <el-date-picker
                    v-if="checkType == 'dateTime'"
                    v-model="leftVal"
                    class="search-select-child"
                    type="datetime"
                    placeholder="选择日期"
                />
                <el-date-picker
                    v-if="checkType == 'dateTime' && isshowRight"
                    v-model="rightVal"
                    class="search-select-child"
                    type="datetime"
                    placeholder="选择日期"
                />
                <div class="search-btn">
                    <el-button
                        type="primary"
                        plain
                        icon="el-icon-search"
                        size="mini"
                        class="search-btn-item"
                        @click="handleQuery"
                        >查询</el-button
                    >
                    <el-popconfirm
                        confirm-button-text="确定"
                        cancel-button-text="取消"
                        icon="el-icon-info"
                        icon-color="green"
                        title="确定导出吗？"
                        @confirm="exportBtn"
                    >
                        <el-button
                            v-show="
                                accessType == '2' ||
                                    accessType == '3' ||
                                    accessType == '4' ||
                                    accessType == '5'
                            "
                            slot="reference"
                            type="primary"
                            plain
                            icon="el-icon-download"
                            size="mini"
                            class="search-btn-item"
                            >导出</el-button
                        >
                    </el-popconfirm>
                    <el-button
                        v-show="
                            accessType == '3' ||
                                accessType == '4' ||
                                accessType == '5'
                        "
                        type="primary"
                        plain
                        icon="el-icon-plus"
                        size="mini"
                        class="search-btn-item"
                        @click="handleAddRow"
                        >新增</el-button
                    >
                    <el-button
                        type="primary"
                        plain
                        icon="el-icon-s-open"
                        size="mini"
                        class="search-btn-item"
                        @click="customerColumnDialogOpen"
                        >自定义列</el-button
                    >
                    <el-button
                        type="primary"
                        plain
                        icon="el-icon-sort"
                        size="mini"
                        class="search-btn-item"
                        @click="openSortDialog"
                        >排序</el-button
                    >
                    <el-button
                        type="primary"
                        plain
                        icon="el-icon-sort"
                        size="mini"
                        class="search-btn-item"
                        @click="uploadSaturationHandle"
                        >更新饱和度</el-button
                    >
                </div>
                <el-dialog
                    title="自定义列字段"
                    :visible.sync="customerColumnDialogVisible"
                    width="600px"
                    :lock-scroll="false"
                    :before-close="customerColumnHandleClose"
                >
                    <el-row :gutter="20" type="flex">
                        <el-col>
                            <el-checkbox
                                v-model="checkAll"
                                :indeterminate="isIndeterminate"
                                @change="handleCheckAllChange"
                                >全选</el-checkbox
                            >
                        </el-col>
                        <el-col>
                            <p
                                class="margin-0"
                                style="text-align: right; padding-right: 30px"
                            >
                                字段列表
                            </p>
                        </el-col>
                    </el-row>
                    <el-checkbox-group
                        v-model="checkedColumn"
                        class="customer-Column-content"
                        @change="handleCheckedCitiesChange"
                    >
                        <el-row
                            v-for="column in previewList.headerAll"
                            :key="column.filedName"
                            :gutter="24"
                            type="flex"
                            style="width: 100%; border-bottom: 1px solid #c0c4cc"
                        >
                            <el-col>
                                <el-checkbox :label="column">
                                    <!-- <el-tooltip  placement="top-start" effect="light">
										<p slot="content" class="margin-0">{{column.filedAlias}}</p>
										<p class="over-ellipsis-1 margin-0" style="width:300px;text-align:left;">{{column.filedAlias}}</p>
									</el-tooltip> -->
                                    <p
                                        class="over-ellipsis-1 margin-0"
                                        style="width: 300px; text-align: left"
                                    >
                                        {{ column.filedAlias }}
                                    </p>
                                </el-checkbox>
                            </el-col>
                            <el-col>
                                <p
                                    class="margin-0"
                                    style="text-align: right; font-size: 14px"
                                >
                                    {{ column.filedName }}
                                </p>
                            </el-col>
                        </el-row>
                    </el-checkbox-group>
                    <span slot="footer" class="dialog-footer">
                        <el-button @click="customerColumnHandleCalcel"
                            >取 消</el-button
                        >
                        <el-button
                            type="primary"
                            @click="customerColumnHandleSure"
                            >确 定</el-button
                        >
                    </span>
                </el-dialog>
                <el-dialog
                    class="sort-dialog"
                    title="排序"
                    :visible.sync="sortDialogVisible"
                    width="600px"
                    :lock-scroll="false"
                    :before-close="sortDialogHandleClose"
                >
                    <el-row>
                        <el-select
                            v-model="sortingField"
                            :multiple="true"
                            placeholder="请选择排序字段"
                            style="width: 100%"
                        >
                            <el-option
                                v-for="item in fieldList"
                                :key="item.fieldName"
                                class="select-more-option"
                                :label="`${item.fieldName}(${item.fieldAlias})`"
                                :value="item.fieldName"
                            >
                                <p
                                    class="over-ellipsis-1 margin-0"
                                    style="text-align: left"
                                >
                                    {{
                                        `${item.fieldName}(${item.fieldAlias})`
                                    }}
                                </p>
                            </el-option>
                        </el-select>
                    </el-row>
                    <el-row>
                        <el-select
                            v-model="sortBy"
                            placeholder="请选择排序方式"
                            style="width: 100%"
                        >
                            <el-option
                                v-for="item in sortByList"
                                :key="item.value"
                                class="select-more-option"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </el-row>
                    <span slot="footer" class="dialog-footer">
                        <el-button @click="sortDialogHandleCalcel"
                            >取 消</el-button
                        >
                        <el-button type="primary" @click="sortDialogHandleSure"
                            >确 定</el-button
                        >
                    </span>
                </el-dialog>
            </el-col>
        </el-row>
        <el-row>
            <div class="data-view-table">
                <el-table
                    :key="tableKey"
                    v-loading="loading"
                    :data="previewList.list"
                    :max-height="mapHeight"
                    class="data-view-table"
                    cell-class-name="timeStyle"
                    border
                    @selection-change="handleSelectionChange"
                    @row-click="handleRowClick"
                >
                    <el-table-column
                        v-for="(item, index) in previewList.header"
                        :key="index"
                        min-width="190"
                        sortable
                        :label="item.filedAlias"
                        :property="item.filedName"
                    >
                        <el-table-column
                            min-width="230"
                            :label="item.filedName"
                        >
                            <template slot-scope="scope">
                                <el-popover
                                    trigger="click"
                                    placement="top"
                                    v-if="
                                        (!scope.row.isEdit ||
                                            item.primaryKey) &&
                                            !scope.row.isAddRow
                                    "
                                    popper-class="popover-cell"
                                >
                                    <span
                                        v-if="
                                            (!scope.row.isEdit ||
                                                item.primaryKey) &&
                                                !scope.row.isAddRow
                                        "
                                        >{{ scope.row[item.filedName] }}</span
                                    >
                                    <div
                                        slot="reference"
                                        :class="'name-wrapper' + scope.row.id"
                                    >
                                        {{ scope.row[item.filedName] }}
                                    </div>
                                </el-popover>
                                <!-- <el-tooltip placement="top-start" effect="light">
                  <p
                    v-if="
                      (!scope.row.isEdit ||
                        item.primaryKey) &&
                        !scope.row.isAddRow
                    "
                    slot="content"
                    class="margin-0"
                  >
                    {{ scope.row[item.filedName] }}
                  </p>
                  <p
                    v-if="
                      (!scope.row.isEdit ||
                        item.primaryKey) &&
                        !scope.row.isAddRow
                    "
                    class="over-ellipsis-1 margin-0"
                  >
                    {{ scope.row[item.filedName] }}
                  </p>
                </el-tooltip>-->
                                <el-input
                                    v-if="
                                        (scope.row.isEdit &&
                                            !item.primaryKey &&
                                            item.dataType !== 'datetime' &&
                                            item.dataType !== 'date' &&
                                            item.dataType != 'timestamp') ||
                                            (scope.row.isAddRow &&
                                                item.dataType != 'datetime' &&
                                                item.dataType != 'date' &&
                                                item.dataType != 'timestamp')
                                    "
                                    v-model="scope.row[item.filedName]"
                                />
                                <el-date-picker
                                    v-if="
                                        ((item.dataType == 'datetime' ||
                                            item.dataType == 'date' ||
                                            item.dataType == 'timestamp') &&
                                            scope.row.isEdit) ||
                                            ((item.dataType == 'datetime' ||
                                                item.dataType == 'date' ||
                                                item.dataType == 'timestamp') &&
                                                scope.row.isAddRow)
                                    "
                                    v-model="scope.row[item.filedName]"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    placeholder="选择日期时间"
                                />
                            </template>
                        </el-table-column>
                    </el-table-column>
                    <el-table-column
                        v-if="
                            accessType == '3' ||
                                accessType == '4' ||
                                accessType == '5'
                        "
                        label="操作"
                        align="center"
                        width="160"
                        fixed="right"
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="!scope.row.isEdit && !scope.row.isAddRow"
                                class="primary-simple-btn simple-btn"
                                plain
                                @click="handleEdit(scope.$index, scope.row)"
                            >
                                编辑
                            </p>
                            <p
                                v-if="scope.row.isEdit || scope.row.isAddRow"
                                class="primary-simple-btn simple-btn"
                                plain
                                @click="handleSave(scope.$index, scope.row)"
                            >
                                保存
                            </p>
                            <p
                                v-if="scope.row.isEdit || scope.row.isAddRow"
                                class="warning-simple-btn simple-btn"
                                plain
                                @click="handleExit(scope.$index, scope.row)"
                            >
                                取消
                            </p>
                            <p
                                v-if="!scope.row.isEdit && !scope.row.isAddRow"
                                class="danger-simple-btn simple-btn"
                                plain
                                @click="handleDelete(scope.$index, scope.row)"
                            >
                                删除
                            </p>
                            <!-- <el-button   type="primary"  size="mini" @click="handleEdit(scope.$index, scope.row)" v-if="(!scope.row.isEdit) && !scope.row.isAddRow" plain>
								编辑
							</el-button>
							<el-button  type="primary" size="mini" @click="handleSave(scope.$index, scope.row)" v-if="(scope.row.isEdit) || scope.row.isAddRow" plain>
								保存
							</el-button>
							<el-button  type="warning" size="mini" @click="handleExit(scope.$index, scope.row)" v-if="(scope.row.isEdit) || scope.row.isAddRow" plain>
								取消
							</el-button>
							<el-button  type="danger" size="mini"  @click="handleDelete(scope.$index, scope.row)" v-if="(!scope.row.isEdit) && !scope.row.isAddRow" plain>
								删除
							</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <div
                    v-if="previewList.list && Number(accessType) < 1"
                    class="not-accessType"
                >
                    更多数据请申请表单权限
                </div>
            </div>
            <pagination
                v-show="total > 0"
                :total="total"
                small
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getDataViewList"
            />
        </el-row>
    </div>
</template>
<script>
import {
    getDateViewList,
    addAndEditDateViewList,
    getFieldsList,
    dateViewExport,
    dataDaturability
} from "@/api/dataManagement/system/info";
import { deepEqual, filterParams, getHeight } from "@/utils/zkComm";
export default {
    name: "MapDetails",
    props: ["accessType"],
    data() {
        return {
            // 遮罩层
            loading: false,
            morehandleValue: "",
            previewList: [],
            isRowEdit: false,
            isAddRow: false,
            mapHeight: undefined,
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 30,
                tableId: ""
            },
            options: [
                {
                    value: "newCreate",
                    label: "导出整表",
                    icon: "el-icon-plus"
                },
                {
                    value: "copyValue",
                    label: "导出筛选结果",
                    icon: "el-icon-document-copy"
                }
            ],
            fieldName: "",
            condition: "",
            leftVal: "",
            rightVal: "",
            fieldList: [],
            conditionList: [],
            isshowRight: false,
            checkType: "number",
            // 自定义列控制
            isFirstRequest: true,
            customerColumnDialogVisible: false,
            checkAll: true,
            checkedColumn: [],
            isIndeterminate: false,
            tableKey: Math.random() * 1000000,
            // 排序控制
            sortDialogVisible: false,
            sortingField: [],
            sortBy: "",
            sortByList: [
                { label: "升序", value: "asc" },
                { label: "倒序", value: "desc" }
            ]
        };
    },
    created() {
        this.queryParams.tableId = this.$route.params.tableId;
        this.getDataViewList();
        this.getFieldsbasicList();
        //   this.uploadSaturationHandle();
    },
    mounted() {
        this.mapHeight = getHeight(true) + 30;
    },
    methods: {
        // 获取数据方法
        // 数据预览列表
        getDataViewList() {
            this.loading = true;
            getDateViewList(this.queryParams).then(res => {
                if (res.code == 200) {
                    // console.log("res:",res)
                    res.data.list.forEach(element => {
                        element.isEdit = false;
                    });
                    // this.previewList = res.data;
                    this.previewList.header = res.data.header || [];
                    this.previewList.list = res.data.list || [];
                    // 自定义列控制
                    if (this.isFirstRequest === true) {
                        this.previewList.headerAll = res.data.header || [];
                        this.checkedColumn = res.data.header || [];
                    } else {
                        this.previewList.header = [...this.checkedColumn];
                    }
                    this.isFirstRequest = false;
                    this.total = res.data.total;
                    this.loading = false;
                    this.mapHeight = getHeight(true) + 30;
                }
            });
        },
        handleSelectField(item) {
            this.isshowRight = false;
            var numList = [
                "tinyint",
                "smallint",
                "int",
                "integer",
                "bigint",
                "float",
                "double",
                "decimal"
            ];
            var dateList = ["date", "datetime", "timestamp"];
            var strList = [
                "char",
                "varchar",
                "tinytext",
                "tinyblob",
                "blob",
                "text",
                "mediumblob",
                "mediumtext",
                "longblob",
                "longtext"
            ];
            var str = [
                { key: "<", val: "lt" },
                { key: "=", val: "eq" },
                { key: "<=", val: "le" },
                { key: ">", val: "gt" },
                { key: ">=", val: "ge" },
                { key: "≠", val: "ne" },
                { key: "(a,b)", val: "(a,b)" },
                { key: "(a,b]", val: "(a,b]" },
                { key: "[a,b)", val: "[a,b)" },
                { key: "[a,b]", val: "[a,b]" },
                { key: "空值", val: "null" },
                { key: "非空", val: "notNull" }
            ];
            if (numList.indexOf(item["dataType"]) != -1) {
                this.conditionList = str;
                this.checkType = "number";
            } else if (strList.indexOf(item["dataType"]) != -1) {
                var dataText = (str = [
                    { key: "包含", val: "contain" },
                    { key: "不包含", val: "notContain" },
                    { key: "开头为", val: "startWith" },
                    { key: "结尾为", val: "endWith" },
                    { key: "精准匹配", val: "eq" },
                    { key: "空值", val: "null" },
                    { key: "非空", val: "notNull" }
                ]);
                this.conditionList = dataText;
                this.checkType = "string";
            } else if (dateList.indexOf(item["dataType"]) != -1) {
                this.conditionList = str;
                this.checkType = "dateTime";
            }
            this.condition = "";
            this.leftVal = "";
            this.condition = "";
            this.rightVal = "";
        },
        handleSelectCondition(item) {
            console.log(item);
            if (["(a,b)", "[a,b)", "(a,b]", "[a,b]"].indexOf(item.key) > -1) {
                this.isshowRight = true;
            } else {
                this.isshowRight = false;
            }
        },
        handleQuery(sort) {
            var that = this;
            that.queryParams.fieldName = undefined;
            that.queryParams.condition = undefined;
            that.queryParams.leftVal = undefined;
            that.queryParams.condition = undefined;
            if(sort=='sort') {
                that.queryParams.sortingField = this.sortingField.toString();
                that.queryParams.sortBy = this.sortBy;
            }
            if (that.fieldName) {
                that.queryParams.fieldName = that.fieldName;
            }
            if (that.condition) {
                that.queryParams.condition = that.condition;
            }
            console.log(this.checkType);
            if (that.leftVal && this.checkType != "dateTime") {
                that.queryParams.leftVal = that.leftVal.replace(/\s/g, "");
            }
            if (that.rightVal && this.checkType != "dateTime") {
                that.queryParams.rightVal = that.rightVal.replace(/\s/g, "");
            }
            console.log(that.fieldName, that.condition, that.leftVal);
            if (
                (that.fieldName && that.condition && that.leftVal) ||
                (that.fieldName &&
                    that.condition &&
                    that.leftVal &&
                    that.rightVal)
            ) {
                that.queryParams.fieldName = that.fieldName;
                that.queryParams.condition = that.condition;
                if (this.checkType != "dateTime") {
                    that.queryParams.leftVal = that.leftVal.replace(/\s/g, "");
                }
                if (that.leftVal && this.checkType == "dateTime") {
                    that.queryParams.leftVal = this.parseTime(
                        new Date(that.leftVal),
                        "{y}-{m}-{d} {h}:{i}:{s}"
                    );
                }
                if (that.rightVal && this.checkType != "dateTime") {
                    that.queryParams.rightVal = that.rightVal.replace(
                        /\s/g,
                        ""
                    );
                }
                if (that.rightVal && this.checkType == "dateTime") {
                    that.queryParams.rightVal = this.parseTime(
                        new Date(that.rightVal),
                        "{y}-{m}-{d} {h}:{i}:{s}"
                    );
                }
                // this.getFieldsbasicList()
                this.getDataViewList();
            } else {
                this.getDataViewList();
                // this.getFieldsbasicList()
            }
        },
        getFieldsbasicList() {
            getFieldsList({ params: this.queryParams }).then(res => {
                if (res.code == 200) {
                    this.fieldList = res.data;
                    
                    // console.log("this.fieldList:",this.fieldList)
                }
            });
        },
        exportBtn() {
            var that = this;
            var { pageNum, pageSize } = that.queryParams;
            var query = {
                pageNum,
                pageSize
            };
             this.$confirm('此下载任务异步到任务列表，请前往任务列表查看', '', {
                confirmButtonText: '去任务列表',
                cancelButtonText: '知道了',
                distinguishCancelAndClose: true,
                type: 'success',
                }).then(() => {
                    this.$router.push('/schedule/list')
                })
            dateViewExport({
                tableId: that.queryParams.tableId,
                query: that.queryParams
            }).then(res => {
                // this.download(res.msg);
            });
        },
        watchContentHandle(e) {
            if (this.checkType == "number") {
                this.leftVal = this.leftVal.replace(/^\.+|[^\d.]/g, "");
                this.rightVal = this.rightVal.replace(/^\.+|[^\d.]/g, "");
                console.log(this.leftVal);
            } else {
                this.leftVal = this.leftVal;
                this.rightVal = this.rightVal;
            }
        },
        handleRowClick() {},
        // 删除
        handleDelete(index, row) {
            this.isRowEdit = false;
            this.isAddRow = false;
            if (this.isRowEdit || this.isAddRow) {
                this.$message({
                    message: "请先保存或取消正在编辑的数据后再进行删除",
                    type: "warning"
                });
                return false;
            }
            const paramsRow = filterParams(row, ["isEdit"]);
            addAndEditDateViewList({
                method: "delete",
                tableId: this.queryParams.tableId,
                data: paramsRow
            })
                .then(res => {
                    if (res.code == 200) {
                        this.$message({
                            message: "删除成功",
                            type: "success"
                        });
                        this.getDataViewList();
                    }
                })
                .catch(() => {
                    this.getDataViewList();
                });
        },
        handleAddRow() {
            if (this.isRowEdit || this.isAddRow) {
                this.$message({
                    message: "先保存再进行新增数据",
                    type: "warning"
                });
                return false;
            }
            var addRow = {};
            for (var i = 0; i < this.previewList.header.length; i++) {
                addRow[this.previewList.header[i].property] = null;
            }
            addRow.isAddRow = true;
            this.isAddRow = true;
            this.previewList.list.push(addRow);
        },
        getpreviewList(index) {
            var previewList = this.previewList.list;
            previewList[index].isEdit = !previewList[index].isEdit;
            if (previewList[index].isAddRow) {
                previewList[index].isAddRow = false;
            }
        },
        deepEqual(object1, object2) {
            const keys1 = Object.keys(object1);
            const keys2 = Object.keys(object2);
            function isObject(obj) {
                return (
                    Object.prototype.toString.call(obj) === "[object Object]"
                );
            }
            if (keys1.length !== keys2.length) {
                return false;
            }
            for (const key of keys1) {
                const val1 = object1[key];
                const val2 = object2[key];
                const areObjects = isObject(val1) && isObject(val2);
                if (
                    (areObjects && !deepEqual(val1, val2)) ||
                    (!areObjects && val1 !== val2)
                ) {
                    return false;
                }
            }
            return true;
        },
        // 编辑
        handleEdit(index, row) {
            if (this.isRowEdit || this.isAddRow) {
                this.$message({
                    message: "请先保存正在编辑的数据后再进行编辑",
                    type: "warning"
                });
                return false;
            }
            this.getpreviewList(index);
            this.isRowEdit = true;
        },
        // 保存
        handleSave(index, row) {
            this.getpreviewList(index);
            this.isRowEdit = false;
            this.isAddRow = false;
            var params = {
                method: "put",
                text: "编辑"
            };
            // this.queryParams.tableId
            delete row.undefined;
            if (row.isAddRow == false) {
                params.method = "post";
                params.text = "新增";
                delete row.isAddRow;
            } else {
                params.method = "put";
                params.text = "编辑";
            }
            const paramsRow = filterParams(row, ["isEdit"]);
            addAndEditDateViewList({
                tableId: this.queryParams.tableId,
                data: paramsRow,
                method: params.method
            })
                .then((res, err) => {
                    if (res.code == 200) {
                        this.$message({
                            message: params.text + "成功",
                            type: "success"
                        });
                        this.getDataViewList();
                    }
                })
                .catch(() => {
                    this.getDataViewList();
                });
            // if(row.isAddRow == false) {
            // 	delete row.isAddRow;
            // 	addAndEditDateViewList({method:'post',tableId:this.queryParams.tableId,data:row}).then(res=>{
            // 		if(res.code == 200){
            // 			this.getDataViewList()
            // 		}
            // 	})
            // } else {
            // 	addAndEditDateViewList({method:'put',tableId:this.queryParams.tableId,data:row}).then(res=>{
            // 		if(res.code == 200){
            // 			this.getDataViewList()
            // 		}
            // 	})
            // }
        },
        handleExit(index, row) {
            if (row.isAddRow) {
                var data = this.previewList.list;
                data.splice(index, 1);
                this.previewList.list = data;
                this.isRowEdit = false;
                this.isAddRow = false;
            } else {
                this.getpreviewList(index);
                this.isRowEdit = false;
            }
            this.getDataViewList();
        },
        handleSelectionChange() {},
        filterParams(obj, arr) {
            const result = {};
            for (var item in obj) {
                if (arr.indexOf(item) == -1) {
                    result[item] = obj[item];
                }
            }
            return result;
        },
        updataHandle() {
            this.fieldName = "";
            this.condition = "";
            this.leftVal = "";
            this.rightVal = "";
            this.sortingField = [];
            this.sortBy = undefined;
            this.queryParams.fieldName = undefined;
            this.queryParams.condition = undefined;
            this.queryParams.leftVal = undefined;
            this.queryParams.sortingField = [];
            this.queryParams.sortBy = undefined;
            this.getDataViewList();
        },
        showPopover(scope) {
            // console.log(this.$refs['showPopover'+index])
            // return {'overflow': 'hidden','text-overflow': 'ellipsis','display': '-webkit-box','-webkit-line-clamp': '2', '-webkit-box-orient': 'vertical'}
        },
        // -------自定义列控制start--------
        customerColumnDialogOpen() {
            this.customerColumnDialogVisible = true;
        },
        customerColumnHandleClose() {
            this.customerColumnHandleCalcel();
        },
        handleCheckAllChange(val) {
            this.checkedColumn = val ? this.previewList.headerAll : [];
            this.isIndeterminate = false;
        },
        handleCheckedCitiesChange(value) {
            const checkedCount = value.length;
            this.checkAll = checkedCount === this.previewList.headerAll.length;
            this.isIndeterminate =
                checkedCount > 0 &&
                checkedCount < this.previewList.headerAll.length;
        },
        customerColumnHandleSure() {
            this.customerColumnDialogVisible = false;
            this.previewList.header = this.checkedColumn;
            this.tableKey = Math.random() * 1000000;
        },
        customerColumnHandleCalcel() {
            this.customerColumnDialogVisible = false;
            this.checkedColumn = this.previewList.header;
        },
        // -------自定义列控制end--------
        openSortDialog() {
            this.sortDialogVisible = true;
        },
        sortDialogHandleClose() {
            this.sortDialogVisible = false;
        },
        sortDialogHandleCalcel() {
            this.sortDialogVisible = false;
        },
        sortDialogHandleSure() {
            this.sortDialogVisible = false;
            this.handleQuery('sort');
        },
        uploadSaturationHandle() {
            this.loading = true;
            dataDaturability({ tableId: this.queryParams.tableId }).then(
                res => {
                    res.data.forEach(element => {
                        element.filedAlias =
                            element.filedAlias +
                            "\xa0\xa0\xa0[" +
                            element.nullSum +
                            "]\xa0[" +
                            element.saturability +
                            "%]";
                    });
                    this.previewList.header = res.data;
                    this.tableKey = Math.random() * 1000000;
                    this.loading = false;
                }
            );
        }
    }
};
// //鼠标划入滚动条展现，鼠标划出滚动条隐藏
// function scrollbarShowHidden(element){
//     element.addClass('scrollbarHide');
//     element.hover(function() {
//         element.addClass('scrollbarShow');
//     }, function() {
//         element.removeClass('scrollbarShow');
//     });

// }

// scrollbarShowHidden($('.el-table__body-wrapper'));
</script>
<style>
@import "~@/assets/styles/utils.scss";
.data-view-table .el-date-editor.el-input {
    width: 159px !important;
}
</style>
<style lang="scss" scoped>
/****
 reset element style
.

 */
 @import "~@/assets/styles/utils.scss";
.data-view-table {
    position: relative;
    .not-accessType {
        font-size: 16px;
        padding: 20px;
        color: #606266;
        background: #ffe399;
        border: 1px solid #ddd;
        position: absolute;
        top: 50%;
        left: 50%;
        margin-left: -109px;
        margin-top: -31px;
    }
}
.el-col-3 {
    width: 70px;
}
.el-col-2 {
    width: 96px;
    margin-right: 10px;
}
/****
 reset element style
.

 */
.operation {
    line-height: 43px;
    padding: 10px 0;
    .search-select-child,
    .search-select-descen,
    .search-select-parent {
        margin-right: 10px;
    }
    .search-select-parent {
        width: 200px;
    }
    .search-select-child,
    .search-select-descen {
        width: 180px;
    }
    .el-button--mini {
        margin-right: 10px;
    }
}
.search-input-list {
    overflow: hidden;
    display: inline-block;
}
.search-btn {
    display: inline-block;
    .search-btn-item {
        display: inline-block;
    }
}
.customer-Column-content {
    height: 450px;
    overflow-y: scroll;
}
.el-checkbox {
    display: flex;
    align-items: center;
    height: 100%;
}
::v-deep .sort-dialog {
    .el-select {
        .el-select__tags {
            .el-tag {
                display: flex !important;
                align-items: center;
            }
            .el-select__tags-text {
                display: inline-block;
                width: 130px;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
                overflow: hidden;
                text-overflow: ellipsis;
                word-wrap: break-word;
            }
        }
    }
}
</style>
